﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SSN.BusinessFramework.Reps;
using SSN.DotNet;
using SSN.Utilities.Cache;

namespace SSN.WebFramework
{
    public static class RepManager
    {
        /// <summary>
        /// Interal cache of the reps;
        /// </summary>
        private static RepCache repCache = new RepCache();

        /// <summary>
        /// Gets a single rep.
        /// </summary>
        /// <param name="repNumber">Rep number</param>
        /// <returns></returns>
        public static Rep GetRepByNumber(string repNumber)
        {
            return repCache[repNumber];
        }

        /// <summary>
        /// Returns a list of reps.
        /// </summary>
        /// <param name="repList">List of rep numbers.</param>
        /// <returns></returns>
        public static List<Rep> GetRepsByNumbers(List<string> repList)
        {
            List<Rep> reps = new List<Rep>();
            foreach (string r in repList)
            {
                Rep rep = repCache[r];
                if (rep != null)
                {
                    reps.Add(rep);
                }
            }

            return reps;
        }
    }
}
